home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / origami / messages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-27  |  9.8 KB  |  340 lines

  1. /*{{{}}}*/
  2. /*{{{  #includes*/
  3. #ifdef CONFIG_H
  4. #   include "config.h"
  5. #endif
  6.  
  7. #include <sys/types.h>
  8. #include <limits.h>
  9. #include <stdio.h>
  10. #include <signal.h>
  11. #include <string.h>
  12.  
  13. #define MESSAGES_C
  14. #define I_GETMSG_C
  15. #define I_INIT_C
  16.  
  17. #include "origami.h"
  18. #include <h/envvar_str.h>
  19. #include <lib/ori_add_lib.h>
  20. /*}}}  */
  21.  
  22. /*{{{  inputs - if possible, this defaults will be overwritten by origamimsg*/
  23. public unsigned char NO=MSG_I_NO;
  24. public unsigned char YES=MSG_I_YES;
  25. public unsigned char AB=MSG_I_AB;
  26. public unsigned char DO_AB=MSG_I_DO_AB;
  27. public unsigned char DO_REST=MSG_I_DO_REST;
  28. /*}}}  */
  29. /*{{{  messages which can/should not be handled in getmsg*/
  30. /*{{{  my name, maybe overwritten by rc-file*/
  31. public unsigned char origami_name[BIND_NAME_LEN+1]="Origami";
  32. /*}}}  */
  33. /*{{{  coding chars 0..31 with @A.. HEX digits*/
  34. public unsigned char const ctrl_decode[]=CTRL_CHARS;
  35. public unsigned char const hex_digits[]=HEX_CHARS;
  36. /*}}}  */
  37. /*{{{  error's, which can occur before msg and rc are read*/
  38. public char const M_FM[]=MSG_M_FM;
  39. public char const M_INV_OCL[]=MSG_M_INV_OCL;
  40. public unsigned char const M_MIS_MES[]=MSG_M_MIS_MES;
  41. public unsigned char const M_IN_MES[]=MSG_M_IN_MES;
  42. public unsigned char const M_NO_MEMORY[]=MSG_M_NO_MEMORY;
  43. public unsigned char const M_NO_MALLOC[]=MSG_M_NO_MALLOC;
  44. public unsigned char const M_INVALID_PATH[]=MSG_M_INVALID_PATH;
  45. /*}}}  */
  46. /*{{{  parts of filename*/
  47. public unsigned char const M_CUT_PATH[]=CUT_PATH;
  48. public char const M_RCSTR[]=RC_ENDING;
  49. public char const M_MSGSTR[]=MSG_ENDING;
  50. public char const M_HELPSTR[]=HELP_ENDING;
  51. /*}}}  */
  52. /*{{{  coding filed folds and attributes*/
  53. public unsigned char const fold_f[]="F ";
  54. public unsigned char const fold_a[]="A ";
  55. /*}}}  */
  56. /*{{{  some texts, used more than once*/
  57. public unsigned char const question[]=" ? ";
  58. #if FOLD_TAG_LENGTH>=3
  59.    public const unsigned char pseudo_mark[]=PSEUDO_MARK;
  60. #else
  61.    extern const unsigned char three_space[]="   ";
  62. #endif
  63. public unsigned char const M_PSTR[]="pipe";
  64. /*}}}  */
  65. /*{{{  paths*/
  66. #ifdef DOC_MSG
  67.    public char const M_DOC_PATH[]=DOC_MSG;
  68. #endif
  69. public char const M_RC_PATH[]=ORIGAMI_RC_PATH;
  70. /*}}}  */
  71. #ifndef REGEXP
  72.    /*{{{  missing functions*/
  73.    public unsigned char const M_NOT_HERE[]=MSG_M_NOT_HERE;
  74.    /*}}}  */
  75. #endif
  76. /*{{{  get_path_strings*/
  77. private void get_path_strings(char *rc,char *help, char *msg)
  78. {
  79.   char *f;
  80.   const char *dummy=MSG_NO_PLACE;
  81.  
  82.   f=open_sysfile(M_MSGSTR,(char*)0);
  83.   strcpy(msg,(*f)?f:dummy);
  84.   f=open_sysfile(M_RCSTR,(char*)0);
  85.   strcpy(rc,(*f)?f:dummy);
  86.   f=open_sysfile(M_HELPSTR,(char*)0);
  87.   strcpy(help,(*f)?f:dummy);
  88. }
  89. /*}}}  */
  90. /*{{{  copyright message*/
  91. #ifdef NO_MSG
  92. #  define copyright False
  93. #else
  94.    public boolean copyright=True;
  95. #endif
  96. /*{{{  get_copyright*/
  97. public unsigned char const *get_copyright(boolean paths)
  98. {
  99.   char rc[_POSIX_PATH_MAX+1];
  100.   char help[_POSIX_PATH_MAX+1];
  101.   char msg[_POSIX_PATH_MAX+1];
  102.  
  103.   if (paths || copyright)
  104.    { if (paths)
  105.         get_path_strings(rc,help,msg);
  106.      return
  107.       ( get_msg
  108.          ( MSG_ARG_FORMAT,
  109. #          ifndef NO_MSG
  110.                MSG_M_CP_INFO
  111. #              ifdef PORTER
  112.                   PORTER
  113. #              endif
  114. #          endif
  115. #          ifdef DOC_MSG
  116.               MSG_M_CP_DOC
  117. #          endif
  118.            "%c\n"
  119.            MSG_PATHS,
  120. #          ifdef DOC_MSG
  121.               M_DOC_PATH,
  122. #          endif
  123.            (paths ? ' ' : '\0'),
  124.            (unsigned char*)M_RC_PATH,
  125.            msg,
  126.            rc,
  127.            help
  128.          )
  129.       );
  130.    }
  131.   else
  132.      return((unsigned char*)empty_text);
  133. }
  134. /*}}}  */
  135. /*}}}  */
  136. /*{{{  the command line argument list*/
  137. public unsigned char const M_S_USAGE[]=
  138.    MSG_USAGE
  139.    "\t" "origami"
  140.    "\t" "[-ehinopvACDPVZ] [-a auto-save-"MSG_CLARG_DELAY"] [-d "MSG_CLARG_DSP_MODE"] [-f " MSG_CLARG_MASTR "]\n"
  141.    "\t" "[-k " MSG_CLARG_NBASE "] [-l " MSG_CLARG_NUMBER "] [-m "MSG_CLARG_MNAME "] [-t " MSG_CLARG_TAB "]\n"
  142.    "\t" "[-F "MSG_CLARG_NMASTR  "] [-K N|A] [-M " MSG_CLARG_MSTRING "] [-N " MSG_CLARG_LLINES "]\n"
  143.    "\t" "[-O " MSG_CLARG_OCLV "] [-R " MSG_CLARG_RC "] [-S " MSG_CLARG_SHELL "] [-T " MSG_CLARG_DEFAULT_NAME "]\n"
  144.    "\t" "[-W " MSG_CLARG_WINNAME "] "
  145. #ifdef OWN_ARG_USAGE_SHORT
  146.                                      OWN_ARG_USAGE_SHORT
  147. #else
  148.                                      "[-X " MSG_CLARG_OSO "]"
  149. #endif
  150.                                                            " [" MSG_CLARG_FILES "]\n"
  151.    MSG_DETAILS
  152. #  ifdef DEBUGGING
  153.    " and debugging options"
  154. #  endif
  155.   "\n"
  156. ;
  157. /*}}}  */
  158. /*{{{  long version of ^*/
  159. /*{{{  string*/
  160. #define first_indent "    "
  161. #define tag_entry(o,s) first_indent "-" o ":\t\t" s "\n"
  162. #define arg_entry(o,a,s)  first_indent "-" o " " a ":\t" s "\n"
  163. private char const M_L_USAGE[]=
  164.    MSG_USAGE "\n"
  165.    first_indent "origami [" MSG_OPTIONS "] [" MSG_CLARG_FILES "]\n"
  166.    "Origami " MAJOR_VERSION "." MINOR_VERSION "." REVISION " " MSG_OPT_ARE ":\n"
  167.    arg_entry("a",MSG_CLARG_DELAY,  MSG_CLOP_a)
  168.    arg_entry("d",MSG_CLARG_DSP_MODE,MSG_CLOP_d)
  169.    tag_entry("e",                  MSG_CLOP_e)
  170.    arg_entry("f",MSG_CLARG_MASTR,  MSG_CLOP_f)
  171.    tag_entry("h",                  MSG_CLOP_h)
  172.    tag_entry("i",                  MSG_CLOP_i)
  173.    arg_entry("k",MSG_CLARG_NAME,   MSG_CLOP_k)
  174.    arg_entry("l",MSG_CLARG_NUMBER, MSG_CLOP_l)
  175.    arg_entry("m",MSG_CLARG_NAME,   MSG_CLOP_m)
  176.    tag_entry("n",                  MSG_CLOP_n)
  177.    tag_entry("o",                  MSG_CLOP_o)
  178.    tag_entry("p",                  MSG_CLOP_p)
  179.    arg_entry("t",MSG_CLARG_WIDTH,  MSG_CLOP_t)
  180.    tag_entry("v",                  MSG_CLOP_v)
  181.    tag_entry("A",                  MSG_CLOP_A)
  182. #  ifdef SW_MSG
  183.    tag_entry("C",                  MSG_CLOP_C)
  184. #  else
  185.    tag_entry("C",                  MSG_CLOP_IGNORE)
  186. #  endif
  187.    tag_entry("D",                  MSG_CLOP_D)
  188.    arg_entry("F",MSG_CLARG_NMASTR, MSG_CLOP_F)
  189.    arg_entry("K",MSG_CLARG_STATE,  MSG_CLOP_K)
  190.    arg_entry("M",MSG_CLARG_MARK,   MSG_CLOP_M)
  191. #  ifdef VIRTUAL
  192.    arg_entry("N",MSG_CLARG_LINES,  MSG_CLOP_N)
  193. #  else
  194.    arg_entry("N",MSG_CLARG_LINES,  MSG_CLOP_IGNORE)
  195. #  endif
  196.    arg_entry("O",MSG_CLARG_VALUE,  MSG_CLOP_O "%s")
  197.    tag_entry("P",                  MSG_CLOP_P)
  198.    arg_entry("R",MSG_CLARG_RC,     MSG_CLOP_R)
  199.    arg_entry("S",MSG_CLARG_SHELL,  MSG_CLOP_S)
  200. #  ifdef WINDOW_TITLE_CHANGE
  201.    arg_entry("T",MSG_CLARG_NAME,   MSG_CLOP_T)
  202. #  else
  203.    arg_entry("T",MSG_CLARG_NAME,   MSG_CLOP_IGNORE)
  204. #  endif
  205.    tag_entry("V",                  MSG_CLOP_V)
  206.    arg_entry("W",MSG_CLARG_NAME,   MSG_CLOP_W)
  207. #  ifdef OWN_ARG_USAGE_LONG
  208.    first_indent  OWN_ARG_USAGE_LONG
  209. #  else
  210.    arg_entry("X",MSG_CLARG_STRING, MSG_CLOP_IGNORE)
  211. #  endif
  212.    tag_entry("Z",                  MSG_CLOP_Z)
  213. #  ifdef DEBUGGING
  214.    "and debugging options:\n"
  215. #  ifdef MALLOC_DEBUG
  216.    arg_entry("@","m",              "display number of malloced bytes")
  217.    arg_entry("@","ms<no>",         "only <xx> bytes can be malloced")
  218.    arg_entry("@","mp<no>",         "malloced paket sizes are multiples of <no>, a power of 2")
  219.    arg_entry("@","m%<no>",         "free looses <no> percent (fragmentation)")
  220.    arg_entry("@","mf<name>",       "malloc writes a dumb to file <name>")
  221. #  ifndef FILE_DEBUG
  222. #     define FILE_DEBUG
  223. #  else
  224. #     ifndef M_FILE_DEBUG
  225. #        define M_FILE_DEBUG
  226. #     endif
  227. #  endif
  228. #  endif
  229. #  ifdef OCL_DEBUG
  230.    arg_entry("@","os",             "show current stack depth")
  231.    arg_entry("@","oS",             "show max reached stack depth")
  232.    arg_entry("@","od",             "screen-off does not switch off the screen, but displays OFF")
  233.    arg_entry("@","ot<delay>",      "sleep for <delay>/1000 seconds between each OCL command")
  234.    arg_entry("@","of<name>",       "dump executed commands on file")
  235.    arg_entry("@","ok<name>",       "dump keyboard input on file")
  236. #  ifndef FILE_DEBUG
  237. #     define FILE_DEBUG
  238. #  else
  239. #     ifndef M_FILE_DEBUG
  240. #        define M_FILE_DEBUG
  241. #     endif
  242. #  endif
  243. #  endif
  244. #  ifdef VIR_DEBUG
  245.    arg_entry("@","v",              "display the size of the virtual file")
  246.    arg_entry("@","vf<name>",       "virtual line handling writes a dumb")
  247. #  ifndef FILE_DEBUG
  248. #     define FILE_DEBUG
  249. #  else
  250. #     ifndef M_FILE_DEBUG
  251. #        define M_FILE_DEBUG
  252. #     endif
  253. #  endif
  254. #  endif
  255. #  ifdef FILE_DEBUG
  256.       "\t\tA missing debug file name causes Origami to use: '" DEBUG_FILE "'\n"
  257. #     ifdef M_FILE_DEBUG
  258.          "\t\tMultiple usage of one debug file is allowed.\n"
  259. #     endif
  260. #  endif
  261. #  endif
  262. #  ifdef DOC_MSG
  263.       MSG_DOC_PATH
  264. #  endif
  265.    MSG_PATHS
  266. ;
  267. /*}}}  */
  268. public unsigned char const *get_long_usage(void)
  269. {
  270.   /*{{{  variables*/
  271.   char rc[_POSIX_PATH_MAX+1];
  272.   char msg[_POSIX_PATH_MAX+1];
  273.   char help[_POSIX_PATH_MAX+1];
  274. #  define HELP_OFF (BIND_NAME_LEN+8)
  275. #  define DEF_TAB 8
  276. #  define DEF_SCR 80
  277.   char opts[HELP_OFF+NO_OCL_CMD_OPTS*(2*BIND_NAME_LEN+2)+2];
  278.   /*}}}  */
  279.  
  280.   /*{{{  get rc-options*/
  281.   opts[0]='\0';
  282.   if (!rcfileparser(opts+HELP_OFF,(char*)0) && opts[HELP_OFF])
  283.    /*{{{  collect all options in one string*/
  284.    { char *o,*p;
  285.      int l;
  286.  
  287.      /*{{{  start message: 'name:'*/
  288.      opts[0]='\n';
  289.      opts[1]=opts[2]='\t';
  290.      strcpy(opts+3,(char*)origami_name);
  291.      for (p=opts;*p;p++);
  292.      l=2*DEF_TAB+ustrlen(origami_name);
  293.      p=opts+l-2*(DEF_TAB-1);
  294.      *p++=':';
  295.      /*}}}  */
  296.      for (o=opts+HELP_OFF;*o;)
  297.       {
  298.         /*{{{  whitespace or newline*/
  299.         if (l++<DEF_SCR-strlen(o))
  300.            *p++=' ';
  301.         else
  302.          { strcpy(p,"\n\t\t\t");
  303.            p+=4;
  304.            l=3*DEF_TAB;
  305.          }
  306.         /*}}}  */
  307.         /*{{{  append*/
  308.         while ((*p = *o++))
  309.          { p++;
  310.            l--;
  311.          }
  312.         /*}}}  */
  313.         /*{{{  skip argument*/
  314.         while (*o++);
  315.         /*}}}  */
  316.       }
  317.      *p='\0';
  318.    }
  319.    /*}}}  */
  320.   /*}}}  */
  321.   get_path_strings(rc,help,msg);
  322.   return
  323.    ( get_msg
  324.       ( MSG_ARG_FORMAT,
  325.         M_L_USAGE,
  326.         MIN_ALARMTIME,
  327.         MAX_ALARMTIME,
  328.         NORM_ALARMTIME,
  329.         opts,
  330.         M_DOC_PATH,
  331.         M_RC_PATH,
  332.         msg,
  333.         rc,
  334.         help
  335.       )
  336.    );
  337. }
  338. /*}}}  */
  339. /*}}}  */
  340.